package org.prototype.bank.facade;

import org.prototype.bank.dao.AccountDao;
import org.prototype.bank.domain.Account;
import org.prototype.bank.domain.Transaction;
import org.prototype.bank.exceptions.TransferException;
import org.prototype.bank.service.TransferService;
import org.springframework.beans.factory.annotation.Autowired;

public class TransferFacadeImpl implements TransferFacade {

	@Autowired
    private TransferService transferService;
	@Autowired
    private AccountDao accountDao;
//    
//    public TransferFacadeImpl(AccountRepository repository, MoneyTransferService service) {
//        this.accountRepository = repository;
//        this.transferService = service;
//    }
//
    public Account createAccount(String accountId, double initialBalance) {
    	Account account = new Account(accountId, initialBalance);
        return accountDao.createAccount(account);
    }

    public double getBalance(String accountId) {
        Account account = accountDao.findAccount(accountId);
        return account.getBalance();
    }

    public Transaction transfer(String fromAccountId,
            String toAccountId, double amount) throws TransferException {
        return transferService.transfer(fromAccountId, toAccountId, amount);
    }
}
